package de.blitzcoder.collide.gui;

import java.awt.Color;
import java.awt.Component;
import javax.swing.BorderFactory;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

/**
 *
 * @author blitzcoder
 */
public class IconTreeRenderer extends DefaultTreeCellRenderer {

    @Override
    public Component getTreeCellRendererComponent(
                        JTree tree,Object value,boolean sel,boolean expanded,
                        boolean leaf,int row,boolean hasFocus) {

        super.getTreeCellRendererComponent(tree, value, sel,expanded, leaf, row,hasFocus);
        
        if (value instanceof IconTreeNode) {
            IconTreeNode node = (IconTreeNode)value;
            setIcon( node.getIcon() );
            if (node.isMarked())
                setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, new Color(200,100,100)));
            else
                setBorder(BorderFactory.createEmptyBorder());
        }

        return this;
    }

    
}
